package ch08;

import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.Date;

class ExceptionEx12 {
	public static void main(String args[]) {
		PrintStream ps = null;
		FileOutputStream fos = null;
		try {
			fos = new FileOutputStream("c:/save/error.log", true);
			ps = new PrintStream(fos);
			System.setErr(ps);

			System.out.println(1);
			System.out.println(2);
			System.out.println(3);
			System.out.println(0 / 0);
			System.out.println(4);
		} catch (Exception ae) {
			System.err.println("-----------------------------------");
			System.err.println("occurred time: " + new Date());
			ae.printStackTrace(System.err);
			System.err.println("error message: " + ae.getMessage());
			System.err.println("-----------------------------------");
		}

		System.out.println(6);
	}
}
/*
 * 1 2 3 6
 */